<?php
namespace JsonRpc\Services\System;
use JsonRpc\Models\SysClient;
use JsonRpc\Models\SysUser;
use JsonRpc\Services\CommonService;
use JsonRpc\Utils\Utils;

/**
 *  用户
 * @author walkor <worker-man@qq.com>
 */
class ClientService
{
    use CommonService;

    private static function getBaseModel(){
        return "JsonRpc\\Models\\SysClient";
    }

    public static function ping(){
        return 'OK';
    }

    public static function saveData($params){
        if(isset($params['id']) && $params['id']){
            //更新
            $model = SysClient::find($params['id']);
            $model->name = $params['name'];
            $model->company_name = $params['company_name'];
            $model->company_address = $params['company_address'];
            $model->company_phone = $params['company_phone'];
        }else{
            //新增
            unset($params['id']);
            $model = new SysClient();
            $model->name = $params['name'];
            $model->company_name = $params['company_name'];
            $model->company_address = $params['company_address'];
            $model->company_phone = $params['company_phone'];
            $model->user_prefix = $params['user_prefix'];
        }
        return $model->save();
    }

    //冻结用户
    public static function remove($params)
    {
        if (!empty($params['id'])) {
            $res = SysClient::where('id',$params['id'])->update([
                'is_active' => '0'
            ]);
            return $res;
        }
        return [];
    }
}
